package cn.xmkeshe;


import cn.xmkeshe.utils.AdminLoginInterceptor;
import cn.xmkeshe.utils.CustomerLoginInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@EnableTransactionManagement
@MapperScan("cn.xmkeshe.dao")
public class StartSpringBootApplication implements WebMvcConfigurer{
  public static void main(String[] args) {
    SpringApplication.run(StartSpringBootApplication.class,args);
  }

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new CustomerLoginInterceptor()).addPathPatterns("/pages/front/**").excludePathPatterns("/**/*.js","/**/*.css","/**/*/.jpg");
    registry.addInterceptor(new AdminLoginInterceptor()).addPathPatterns("/pages/back/**").excludePathPatterns("/**/*.js","/**/*.css","/**/*/.jpg");
  }
}
